<template>
  <div>
     <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区 -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="queryInfo.query" class="input-with-select">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 订单列表区域 -->
      <el-table
        :data="orderList"
        style="width: 100%" border stripe>
          <el-table-column
          type="index"
          label="#">
        </el-table-column>
        <el-table-column
          prop="order_number"
          label="订单编号">
        </el-table-column>
        <el-table-column
          prop="order_price"
          label="订单价格"
          width="100">
        </el-table-column>
        <el-table-column
          prop="order_pay"
          label="是否付款" width="100">
           <template v-slot="slotProps">
            <el-tag type="danger" v-if="slotProps.row.order_pay === '0'" size="mini">未付款</el-tag>
            <el-tag type="success" v-else-if="slotProps.row.order_pay === '1'" size="mini">已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="is_send"
          label="是否发货" width="100">
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="下单时间" width="150">
          <template v-slot="slotProps">
            {{ slotProps.row.create_time | formatDate }}
          </template>
        </el-table-column>
        <el-table-column
          label="操作" width="150">
          <el-button type="primary" class="el-icon-edit" size="mini"></el-button>
          <el-button type="success" class="el-icon-location-outline" size="mini"></el-button>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      orderList: [], // 订单列表数据
      queryInfo: {
        query: '',
        pagenum: 1,
        pagesize: 5
      }
    }
  },
  created () {
    this.getOrderList()
  },
  methods: {
    async getOrderList () {
      const { data: res } = await this.$http.get('orders', { params: this.queryInfo })
      if (res.meta.status !== 200) return this.$msg.error('获取定单列表失败！')
      this.orderList = res.data.goods
      console.log(this.orderList)
    }
  }
}
</script>

<style lang="less" scoped>

</style>
